package com.js.rtu.config;

import com.js.rtu.RTUApplication;
import com.js.rtu.util.SPUtils;

/**
 * 1.64协议指令集合
 * 命令帧
 * <p>
 * Start:起始字
 * Address:终端（RTU） 通信地址, 按用户要求或现场具体情况设置.
 * Length:帧长, 十六进制 2 字节(低字节在前), 帧长包括（Address＋Lengh＋Cmd＋Data＋CRC） .
 * Cmd:命令字, 1 字节.
 * Data:信息段.
 * CRC:校验位, （Address＋Length＋Cmd＋Data） 两字节 CRC 校验低字节在前,
 * CRC 校验采用正序.
 * End:停止字
 * Created by wz on 2020/6/17.
 */

public class CmdConfig {


    /**
     * 调试信息输出
     */
    public static boolean isDebug;

    /**
     * 设置成功
     */
    public static final String SUCCECC = "00";
    /**
     * 设置失败
     */
    public static final String FAIL = "01";

    /**
     * 帧头
     */
    public  static final String CMD_HEADER = "EE EE";
    /**
     * 地址，默认30 30 30 30 30 30 30 30
     */
    public static String CMD_ADDRESS;
    /**
     * 帧尾部
     */
    public  static final String CMD_FOOTER = "FF FF";

    /**
     * 01交互完通知帧
     */
    public static final String CMD_01 = "01";
    /**
     * 02实时点测
     */
    public static final String CMD_02 = "02";
    /**
     * 03定时自报
     */
    public static final String CMD_03 = "03";

    /**
     * 04参数实时报警
     */
    public static final String CMD_04 = "04";
    /**
     * 05参数恢复报警
     */
    public static final String CMD_05 = "05";
    /**
     * 06自报多组数据
     */
    public static final String CMD_06 = "06";
    /**
     * 08补调
     */
    public static final String CMD_08 = "08";
    /**
     * 09打包补调历史数据
     */
    public static final String CMD_09 = "09";
    /**
     * 10终端报警
     */
    public static final String CMD_10 = "10";
    /**
     * 11查询终端时钟
     */
    public static final String CMD_11 = "11";
    /**
     * 12查询终端工作参数
     */
    public static final String CMD_12 = "12";
    /**
     * 13查询终端地址、 中心站地址
     */
    public static final String CMD_13 = "13";
    /**
     * 14查询开关量逻辑状态
     */
    public static final String CMD_14 = "14";
    /**
     * 15查询终端通信口参数
     */
    public static final String CMD_15 = "15";
    /**
     * 16查询脉冲量 PI 设置值及满量程
     */
    public static final String CMD_16 = "16";
    /**
     * 17查询参数限值
     */
    public static final String CMD_17 = "17";
    /**
     * 18查询短信报警号码
     */
    public static final String CMD_18 = "18";

    /**
     * 19查询终端报警允许/禁止命令
     */
    public static final String CMD_19 = "19";
    /**
     * 20查询终端报警允许/禁止命令
     */
    public static final String CMD_20 = "20";
    /**
     * 21校时命令
     */
    public static final String CMD_21 = "21";
    /**
     * 22设置终端工作参数
     */
    public static final String CMD_22 = "22";

    public static final String CMD_22_01 = "01";//定时采集间隔
    public static final String CMD_22_02 = "02";//定时存储间隔
    public static final String CMD_22_03 = "03";//定时自报间隔
    public static final String CMD_22_04 = "04";//基准电压
    public static final String CMD_22_05 = "05";//工作模式
    public static final String CMD_22_06 = "06";//终端报警间隔及次数
    public static final String CMD_22_07 = "07";//模拟量表计类型及输出范围
    public static final String CMD_22_08 = "08";//根据供电方式切换工作模式
    public static final String CMD_22_09 = "09";//设置模拟量表计供电时间
    public static final String CMD_22_0B = "0B";//多段自报间隔
    public static final String CMD_22_EE = "EE";//控制终端状态


    /**
     * 23设置终端地址、 中心站地址
     */
    public static final String CMD_23 = "23";
    public static final String CMD_23_10 = "10";//终端出厂编号
    public static final String CMD_23_11 = "11";//DTU 识别号
    public static final String CMD_23_12 = "12";//主中心IP 地址
    public static final String CMD_23_13 = "13";//主中心端口号
    public static final String CMD_23_14 = "14";//接入点 APN
    public static final String CMD_23_15 = "15";//中心域名
    public static final String CMD_23_16 = "16";//用户名
    public static final String CMD_23_17 = "17";//用户密码
    public static final String CMD_23_19 = "19";//多中心参数

    public static final String CMD_23_20= "20";//出厂编号


    /**
     * 24设置开关量逻辑状态
     */
    public static final String CMD_24 = "24";
    /**
     * 25设置通信口参数
     */
    public static final String CMD_25 = "25";
    /**
     * 26设置脉冲量 PI 初值及满量程
     */
    public static final String CMD_26 = "26";
    /**
     * 27设置参数限值
     */
    public static final String CMD_27 = "27";

    public static final String CMD_27_0A = "0A";//模拟量
    public static final String CMD_27_0D = "0D";//开关量
    public static final String CMD_27_0F = "0F";//流量计

    /**
     * 28设置短信报警号码
     */
    public static final String CMD_28 = "28";
    /**
     * 29设置终端报警允许/禁止命令
     */
    public static final String CMD_29 = "29";
    /**
     * 30远程升级
     */
    public static final String CMD_30 = "30";
    /**
     * 31加密模块
     */
    public static final String CMD_31 = "31";
    /**
     * 报警历史查询
     */
    public static final String CMD_40 = "40";


    /**
     * 51遥控
     */
    public static final String CMD_51 = "51";
    /**
     * 90查询终端内部工作状态
     */
    public static final String CMD_90 = "90";
    /**
     * 91重启设备
     */
    public static final String CMD_91 = "91";
    /**
     * 92查询所有参数
     */
    public static final String CMD_92 = "92";
    /**
     * FE未知指令/指令错误
     */
    public static final String CMD_FE = "FE";
    /**
     * ini文件路径
     */
    public static String PATH;
    /**
     * 心跳,默认15S
     */
    public static int TIME_BEAT;

    /**
     * 超时时间,默认15S
     */
    public static int TIME_OUT;


    static {
        RTUApplication localBaseApp = RTUApplication.getInstance();
        isDebug = (boolean) SPUtils.get(localBaseApp, "isDebug", true);
        CMD_ADDRESS = (String) SPUtils.get(localBaseApp, "cmd_address", "30 30 30 30 30 30 30 30");
        PATH = (String) SPUtils.get(localBaseApp, "path", "");
        TIME_BEAT = (int) SPUtils.get(localBaseApp, "time_beat", 20);
        TIME_OUT = (int) SPUtils.get(localBaseApp, "time_out", 15);



    }


}
